import request from '@/utils/request'

// 查询数据源列表
export function listDatasource(query) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/list',
    method: 'get',
    params: query
  })
}

// 查询数据源详细
export function getDatasource(dsId) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/' + dsId,
    method: 'get'
  })
}

// 新增数据源
export function addDatasource(data) {
  return request({
    url: 'ldzl-rpt/rpt/datasource',
    method: 'post',
    data: data
  })
}

// 修改数据源
export function updateDatasource(data) {
  return request({
    url: 'ldzl-rpt/rpt/datasource',
    method: 'put',
    data: data
  })
}

// 删除数据源
export function delDatasource(dsId) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/' + dsId,
    method: 'delete'
  })
}

// 测试数据源连接
export function testDatasource(data) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/test',
    method: 'post',
    data: data
  })
}

// 查询数据源的表信息
export function listTables(dsId) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/tables/' + dsId,
    method: 'get'
  })
}

// 查询表的列信息
export function listColumns(dsId, tableName) {
  return request({
    url: 'ldzl-rpt/rpt/datasource/columns',
    method: 'get',
    params: {
      dsId: dsId,
      tableName: tableName
    }
  })
} 